﻿<%@ Page Language="C#" ValidateRequest="false" Trace="false" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="findunusedtexts.aspx.cs" Inherits="FindUnusedTextsPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
		
		<script>
		function validateFindUnusedStep1Form()
		{
			valDisplayer.hideAllValidationErrors();
			var noErrors = true;

			var pathElem = $("#<% =  PathTxt.ClientID %>");
			var extensionsElem = $("#<% = ExtensionsTxt.ClientID %>");
			var regexElem = $("#<% = RegexTxt.ClientID %>");
			if (!pathElem.val())
			{
				valDisplayer.showValidationError("Required", pathElem);
				noErrors = false;
			}
			if (!extensionsElem.val())
			{
				valDisplayer.showValidationError("Required", extensionsElem);
				noErrors = false;
			}
			if (!regexElem.val())
			{
				valDisplayer.showValidationError("Required", regexElem);
				noErrors = false;
			}			

			return noErrors;
		}

		function validateFindUnusedStep2Form()
		{
			valDisplayer.hideAllValidationErrors();
			var noErrors = true;

			return noErrors;
		}				
	</script>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="body" Runat="Server">

	<form id="mainForm" runat="server">

		<asp:PlaceHolder runat="server" Visible="true" ID="Step1Plh">

			<h1 class="page">Find unused texts - Wizard Step 1/2</h1>
	
			<p>
				This tool lets you find and remove texts that are not used anywhere in your solution. Texts must be in a specific format which is recognized by the regular expression. The predefined regular expression finds texts in the format seen in this example.
				<div style="margin-left: 10px;">
					<code>
						&lt;% = Txt.GetWeb("news_headline") %&gt;
					</code>
				</div>
			
			</p>

			<h2 class="page">Input</h2>
			<p>
				Start by defining the criteria by which the unused texts is to be found. On the next page you will be allowed to review the texts that will be removed and decide if you want to commit the change to your project file.
			</p>

			<asp:PlaceHolder runat="server" visible="false" ID="Step1ErrorPlh"><asp:Literal id="Step1ErrorLit" runat="server"></asp:Literal></asp:PlaceHolder>			

			<label>Path</label> <span class="explanatory">(folder to be crawled - e.g. c:\websites\superapp\www_app)</span><br />
			<input type="text" style="width: 450px;" value="" id="PathTxt" name="PathTxt" runat="server" /><br />
			<br />
			<label>Extensions to include <span class="explanatory">(separate with comma)</span></label><br />
			<input type="text" style="width: 450px;" value="aspx,ascx,cs" id="ExtensionsTxt" name="PathTxt" runat="server" /><br />			
			<br />
			<label>Regex to use for finding texts <span class="explanatory">(must contain named match &quot;definitionmatch&quot; and optionally &quot;defaulttextmatch&quot;)</span></label><br />
			<input type="text" style="width: 450px;" value="Txt.Get[\w]*\(\&quot;(?<definitionmatch>([\w]*))\&quot;\)(\s*/[\*]{3}(?<defaulttextmatch>(.|\s)*?)[\*]{3}/)?" id="RegexTxt" name="RegexTxt" runat="server" /><br />			

			<div class="actionButton">			
				<button type="submit" onclick="if ( ! validateFindUnusedStep1Form()) { return false;	}" onserverclick="ContinueStep1Clicked" class="mainSubmit" runat="server">Continue</button>
			</div>
		
		</asp:PlaceHolder>
		<asp:PlaceHolder runat="server" Visible="false" ID="Step2Plh">
		
			<h1 class="page">Find unused texts - Wizard Step 2/2</h1>
			
			<p>
				Review the summary and when press &quot;Remove unused texts from project file&quot; when you are ready.
			</p>
			<p>
				Once the changes have been committed you will not be able to undo the changes, so always back up your project file first.
			</p>

			<h2 class="page">Criteria used for text searching</h2>
		
			<div style="font-style: italic;margin-bottom: 5px;">Path: <asp:Literal ID="PathLit" runat="server"></asp:Literal></div>			
			<div style="font-style: italic;margin-bottom: 5px;">Extensions: <asp:Literal ID="ExtensionsLit" runat="server"></asp:Literal></div>			
			<div style="font-style: italic;margin-bottom: 5px;">Regex: <asp:Literal ID="RegexLit" runat="server"></asp:Literal></div>

			<h2 class="page">Unused texts found</h2>
			<p>
				These are the <b><asp:Literal ID="NumberOfUnusedTexts" runat="server"></asp:Literal> texts</b> that was not found anywhere in any of the searched source code.
			</p>
			
			<table class="grid" width="100%">
			
			<asp:Repeater ID="FoundUnusedTextDefinitionNameRpt" runat="server">
				<ItemTemplate>
					<tr>
						<td><%# Container.DataItem %></td>
					</tr>
				</ItemTemplate>
			</asp:Repeater>
			
			</table>
			
			<div class="actionButton">
				<button id="ContinueStep2" type="submit" onclick="if ( ! validateFindUnusedStep2Form()) { return false;	}" onserverclick="ContinueStep2Clicked" class="mainSubmit" runat="server">Remove unused texts from project file</button>
			</div>
					
		</asp:PlaceHolder>


		<asp:PlaceHolder runat="server" Visible="false" ID="SuccessPlh">
		
			<h1 class="page">Find unused texts - Completed</h1>
			
			<p>
				The unused texts have been removed successfully.
			</p>
			
		</asp:PlaceHolder>


	</form>

</asp:Content>
